//
//  BaseUITableViewController.m
//  ShareParking
//
//  Created by STAR on 2017/7/29.
//  Copyright © 2017年 zjw. All rights reserved.
//

#import "BaseUITableViewController.h"

@interface BaseUITableViewController ()

@end

@implementation BaseUITableViewController
- (void)loadView {
    [super loadView];
    [self configNavBackgroundColorUI];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    self.page = 1;
    self.rows = 10;
    self.maxpage = 1;
    self.dataSoureArray = [[NSMutableArray alloc]init];
    self.recordArray = [[NSMutableArray alloc]init];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self configNavBackgroundColorUI];
}

- (void)configNavBackgroundColorUI {
 //   [Utils SetNaviBarGrayStyle:self];
 //   [Utils setNavigationBarLeftButtonWithImage:self imgName:@"back" actionName:@selector(back)];
    self.navigationController.navigationBarHidden = NO;
}

-(void)addRefresh{
    
 //   self.tableView.mj_header =  [ZYRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNew)];
   // self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
    //self.tableView.mj_footer.automaticallyHidden = YES;
//    [self.tableView.mj_header beginRefreshing];
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
 //   [self mb_showSVProgress];
    if (!self.tableView.tableFooterView){ //如果没有footerView 就设置一个默认的
        self.tableView.tableFooterView = [UIView new];
    }

}
-(void)addHeaderRefresh{
  //  self.tableView.mj_header = [ZYRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNew)];
}
-(void)addFooterRefresh{
  //  self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
  //  self.tableView.mj_footer.automaticallyHidden = YES;
}
- (void)endRefresh {
  //  [self.tableView.mj_header endRefreshing];
  //  [self.tableView.mj_footer endRefreshing];
  //  [self mb_hideSVProgress];
}
-(void)loadNew{
    self.page = 1;
  //  [self.tableView.mj_footer resetNoMoreData];
    [self loadDataFromService];

}

-(void)loadMore{
    if (![self hasMore]) {
   //     [self.tableView.mj_footer endRefreshingWithNoMoreData];
        return;
    }
    self.page ++;
    [self loadDataFromService];

}
- (void)loadDataFromService {
    
}

-(NSArray *)dealWithDest:(NSArray *)destArray sourceArray:(NSArray *)sourceArray {
    NSMutableArray *dest = [NSMutableArray arrayWithArray:destArray];
    NSMutableArray *source = [NSMutableArray arrayWithArray:sourceArray];
    self.recordArray = source;
    [self endRefresh];
    if (self.page == 1){
        dest = source;
    }else{
        [dest addObjectsFromArray:source];
    }
    return dest;
}

- (BOOL)hasMore {
    return self.page<self.maxpage;
}
- (void)back {
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - DZNEmptyDataSetSource,DZNEmptyDataSetDelegate

- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    //    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    return  [UIImage imageNamed:@"drink－20"];
    
}


- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
//    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  //  NSString *text =  delegate.hasNetwork ? @"暂无数据..." : @"网络不给力...";
    
  //  NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16],
                               //  NSForegroundColorAttributeName: [UIColor color_1D1D26]};
return nil;
 //   return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
    return YES;
}

@end
